<script language="javascript">
var counter=1;
function hapus_row(obj){	
	 if (confirm('Apakah data akan dihapus ?')) {
  		obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
	}
}
function add_row_komp(id_komp,nama_komp) {
        var tombol_aksi = '<a href="javascript:void(null)" title="Hapus" onclick="hapus_row(this)"><button type="button" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></button></a>';
  		var tr = document.createElement('tr');
  		var td_nama_komp = document.createElement('td');
		var td_nominal = document.createElement('td');
		
  		var td_aksi = document.createElement('td');  		
  		var tbodi = document.getElementById("tbody_list_komp");
  		
  		td_aksi.className = 'links';
  		td_aksi.width = 15;
  		
		td_nama_komp.innerHTML = nama_komp+"<input type='hidden' name='id_komp[]' id='id_komp_"+counter+"' value='"+id_komp+"' >";
		td_nominal.innerHTML = "<input type='text' name='nominal[]' id='nominal_"+counter+"' class='form-control input-sm' size='10'>";

  		td_aksi.innerHTML = tombol_aksi;
  		
  		tr.appendChild(td_nama_komp);
		tr.appendChild(td_nominal);

  		tr.appendChild(td_aksi);
  		tbodi.appendChild(tr);
		counter++;
		
}
</script>
<!-- komponen Modal -->
<div class="modal fade" id="pop_komponen" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div id="popup_pembayaran"></div>
		</div>
	</div>
</div>
<!-- end komponen modal -->
<div id="page-wrapper">
        <!-- /.row -->
    <div class="row">
        <div class="col-sm-12">
			<div class="panel panel-default">
                <div class="panel-heading"><span class="judul-page">Data Siswa</span><span class="pull-right">
					<a class="btn btn-warning btn-xs" href="<?php echo site_url('pembayaran_bebas');?>">&nbsp;Kembali</a>
				</span>
				<div class="clearfix"></div>
				</div>
                <div class="panel-body">
				<?php
$flashmessage = $this->session->flashdata('pesan');
$flasherror = $this->session->flashdata('pesan_error');
	//echo ! empty($flashmessage) ? '<div class="valid_box">' . $flashmessage . '</div>': '';
if(! empty($flashmessage)){
?>
<div class="alert alert-success">
    <span class="glyphicon glyphicon-ok"></span>&nbsp;&nbsp;<?php echo $flashmessage;?>
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
</div>
<?php
}
?>
					<table class="table table-striped table-bordered table-hover table-condensed">
							<tr>
								<td style="width:200px;"><span class="pull-left judul-hub">NVA</span></td>
								<td><?php echo $detail_siswa[0]->nis;?></td>
							</tr>
							<tr>
								<td><span class="pull-left judul-hub">Nama</span></td>
								<td><?php echo $detail_siswa[0]->nm_lengkap;?></td>
							</tr>
							<tr>
								<td><span class="pull-left judul-hub">Tahun Ajaran</span></td>
								<td><b><?php echo $tapel['th_ajaran'];?></b></td>
							</tr>
							
							
						</table>
				</div>
			</div>
			<div class="panel panel-default">
                <div class="panel-heading"><span class="judul-page">History Pembayaran</span></div>
                <div class="panel-body">
					<table class="table table-striped table-bordered table-hover table-condensed">
						<thead>
						<tr>
							<th width="20">No</th>
							<th>Komponen</th>
							<th>Tgl Bayar</th>
							<th>Nominal</th>
							<th>Hapus</th>
						</tr>
						</thead>
						<?php
						if(isset($list_lunas)){
							$no=1;
							foreach($list_lunas as $val){
						
						?>
						<tr>
							<td><?php echo $no; ?></td>
							<td><?php echo $val['nama_komp'];?></td>
							<td><?php echo tgl_indonesia($val['tgl_bayar']);?></td>
							<td><?php echo number_format($val['nominal'],0,",",".");?></td>
							<td>
							<a href="<?php echo site_url('pembayaran_bebas/delete_pembayaran/'.$val['id'].'/'.$nis);?>" onclick="return confirm('Yakin Anda akan menghapus data pembayaran bebas?')" class="btn btn-danger btn-xs" title="Hapus"><span class="glyphicon glyphicon-trash"></span></a>
							</td>
						</tr>
						
						<?php
						$no++;
						}
						}
						?>
					
					</table>
				</div>
			</div>
			<div class="panel panel-default">
                <div class="panel-heading"><span class="judul-page">Pembayaran Tagihan</span></div>
				<div class="panel-body">
				<form action="<?php echo site_url('pembayaran_bebas/proses_pembayaran');?>" name="frm_bayar" id="frm_bayar" method="post">
					<div class="form-group">
							<label class="col-sm-3 control-label">Jenis Komponen</label>
							<div class="col-sm-8"><p class="form-control-static">
								<span class="pull-right">
					<a href="#" class="btn btn-warning btn-xs" style="margin-bottom: 5px;" onclick="show_popup()" data-toggle="modal" data-target="#pop_komponen"><span class="glyphicon glyphicon-plus"></span>&nbsp;Tambah Komponen</a>
				</span>
				<!-- <div class="panel-body"> -->
					<table class="table table-striped table-bordered table-hover table-condensed">
						<thead>
							<tr>
								<th>Nama Komponen</th>
								<th width="35%">Nominal</th>
								<th width="40"></th>
							</tr>
						</thead>
						<tbody id="tbody_list_komp">
						</tbody>
					</table>
				<!-- </div> --></p>
							</div>
					
					<div class="form-group" >
                        <div class="col-sm-offset-3 col-sm-8">
						<input type="hidden" name="nis" value="<?php echo $nis;?>" />
						  <input type="submit" value="Simpan" name="kirim" class="btn btn-primary btn-sm">
                          <button type="reset" class="btn btn-danger btn-sm">Reset</button>
                        </div>
                      </div>
				</form>
				</div>
			</div>
        </div>
    </div>
    <!-- /.row -->
</div>
<!-- /#page-wrapper -->
<script type="text/javascript">
    /*$('#saudaraModal').modal(options);
    $('#ortuModal').modal(options);
    $('#editSModal').modal(options);*/	
	
	function show_popup(){
		$.ajax({
			type: "POST",
			url : "<?php echo site_url(); ?>mr_komp_pembayaran/popup_komponen",
			data: "jenis=bebas",
			cache: false,
			success: function(response) {
				$('#popup_pembayaran').html(response);
			}
		});
		return false;
	}	
</script>